cmake_minimum_required(VERSION 3.16)

project(EIS_Desktop VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 REQUIRED COMPONENTS Quick)
find_package(Qt6 REQUIRED COMPONENTS Core)
find_package(Qt6 REQUIRED COMPONENTS Core)

qt_standard_project_setup(REQUIRES 6.8)

set(QML_FILES
    qml/App.qml
    qml/MainWindow.qml
    qml/components/DeviceList.qml
    qml/components/Results.qml
    qml/components/ServerConnect.qml
    qml/components/TaskTable.qml
    qml/components/ScatterChart.qml
    qml/pages/Device.qml
    qml/ResultsWindow.qml
)

set(SOURCES_FILES
    src/main.cpp
    src/client.cpp
    src/device.cpp
    src/task.cpp

    src/device.h
    src/types.h
    src/client.h
    src/stdafx.h
    src/task.h
    src/result.h
)

set(RESOURCES_FILES
    res/favicon.ico
)

qt_add_executable(${PROJECT_NAME}
    ${SOURCES_FILES}
)


target_link_libraries(EIS_Desktop PRIVATE Qt6::Core)
target_link_libraries(EIS_Desktop PRIVATE Qt6::Core)
qt_add_qml_module(${PROJECT_NAME}
    URI EIS_Desktop
    VERSION 1.0
    RESOURCE_PREFIX /
    RESOURCES ${RESOURCES_FILES}
    QML_FILES ${QML_FILES}
)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(${PROJECT_NAME} PROPERTIES
#    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.${PROJECT_NAME}
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

target_include_directories(${PROJECT_NAME} PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_link_libraries(${PROJECT_NAME}
    PRIVATE Qt6::Quick
)

include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
